# from duckduckgo_search import DDGS

# 设置代理（HTTP/SOCKS5 均可）
proxies = {
            "https": "192.168.2.18:20171",
            "http": "192.168.2.18:20171"
        }

# headers = {
#     "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
#     "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
#     "Referer": "https://www.google.com/ ",
#     "Accept-Language": "en-US,en;q=0.5",
# }


# # 使用代理进行搜索
# with DDGS(proxies=proxies, headers=headers) as ddgs:
#     for r in ddgs.text("Python 异步编程", max_results=5):
#         print(r)



import requests

base_url = "http://localhost:8080"
query = "人工智能的发展"

# data = {
#     "q": query,
#     "format": "json",
#     "pageno": 1,
#     "time_range": "year",  # 可选时间范围
#     "categories": "general",  # 指定搜索类别
#     "engines": "duckduckgo"
# }

data = {
    "query": "python"
}

response = requests.post(f"{base_url}/search", data=data)

print("111111111111", response.text)

# if response.status_code == 200:
#     results = response.json()
#     for result in results.get("results", []):
#         print("标题:", result["title"])
#         print("链接:", result["url"])
#         print("摘要:", result.get("content", ""))
#         print("-" * 50)
# else:
#     print("请求失败，状态码：", response.status_code)